package com.java.service.impl;

import com.java.entity.Deliveryinfo;
import com.java.dao.DeliveryinfoDao;
import com.java.service.DeliveryinfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Deliveryinfo)表服务实现类
 *
 * @author makejava
 * @since 2021-01-20 18:54:56
 */
@Service("deliveryinfoService")
public class DeliveryinfoServiceImpl implements DeliveryinfoService {
    @Resource
    private DeliveryinfoDao deliveryinfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param dId 主键
     * @return 实例对象
     */
    @Override
    public Deliveryinfo queryById(Integer dId) {
        return this.deliveryinfoDao.queryById(dId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Deliveryinfo> queryAllByLimit(int offset, int limit) {
        return this.deliveryinfoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param deliveryinfo 实例对象
     * @return 实例对象
     */
    @Override
    public Deliveryinfo insert(Deliveryinfo deliveryinfo) {
        this.deliveryinfoDao.insert(deliveryinfo);
        return deliveryinfo;
    }

    /**
     * 修改数据
     *
     * @param deliveryinfo 实例对象
     * @return 实例对象
     */
    @Override
    public Deliveryinfo update(Deliveryinfo deliveryinfo) {
        this.deliveryinfoDao.update(deliveryinfo);
        return this.queryById(deliveryinfo.getDId());
    }

    /**
     * 通过主键删除数据
     *
     * @param dId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer dId) {
        return this.deliveryinfoDao.deleteById(dId) > 0;
    }
}